package com.springsource.a03beanlifecycle;

import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

@Component
public class LifecycleBean {

    private static final Logger log = org.slf4j.LoggerFactory.getLogger(LifecycleBean.class);

    public LifecycleBean() {
        log.info("LifecycleBean constructor");
    }

    @Autowired
    public void autowire(@Value("${JAVA_HOME}") String javaHome) {
        log.info("LifecycleBean autowire: JAVA_HOME={}", javaHome);
    }

    @PostConstruct
    public void init() {
        log.info("LifecycleBean init");
    }

    @PreDestroy
    public void destroy() {
        log.info("LifecycleBean destroy");
    }

}
